/*     */ package change.org.eclipse.swt.browser;
/*     */ 
/*     */ import org.eclipse.swt.SWT;
/*     */ import org.eclipse.swt.layout.GridData;
/*     */ import org.eclipse.swt.layout.GridLayout;
/*     */ import org.eclipse.swt.layout.RowLayout;
/*     */ import org.eclipse.swt.widgets.Button;
/*     */ import org.eclipse.swt.widgets.Composite;
/*     */ import org.eclipse.swt.widgets.Dialog;
/*     */ import org.eclipse.swt.widgets.Display;
/*     */ import org.eclipse.swt.widgets.Event;
/*     */ import org.eclipse.swt.widgets.Label;
/*     */ import org.eclipse.swt.widgets.Listener;
/*     */ import org.eclipse.swt.widgets.Shell;
/*     */ import org.eclipse.swt.widgets.Text;
/*     */ import org.eclipse.swt.widgets.Widget;
/*     */ 
/*     */ class MozillaPromptDialog extends Dialog
/*     */ {
/*     */   public MozillaPromptDialog(Shell parent, int style)
/*     */   {
/*  20 */     super(parent, style);
/*     */   }
/*     */ 
/*     */   public MozillaPromptDialog(Shell parent) {
/*  24 */     this(parent, 0);
/*     */   }
/*     */ 
/*     */   public void confirmEx(String title, String text, final String check, String button1, String button2, String button3, final int[] checkValue, final int[] result) {
/*  28 */     Shell parent = getParent();
/*  29 */     final Shell shell = new Shell(parent, 67680);
/*  30 */     shell.setText(title);
/*  31 */     GridLayout gridLayout = new GridLayout();
/*  32 */     shell.setLayout(gridLayout);
/*  33 */     Label label = new Label(shell, 64);
/*  34 */     label.setText(text);
/*  35 */     GridData data = new GridData();
/*  36 */     data.horizontalAlignment = 4;
/*  37 */     data.grabExcessHorizontalSpace = true;
/*  38 */     label.setLayoutData(data);
/*     */ 
/*  40 */     final Button[] buttons = new Button[4];
/*  41 */     Listener listener = new Listener() {
/*     */       public void handleEvent(Event event) {
/*  43 */         if (buttons[0] != null) checkValue[0] = ((buttons[0].getSelection()) ? 1 : 0);
/*  44 */         Widget widget = event.widget;
/*  45 */         for (int i = 1; i < buttons.length; ++i) {
/*  46 */           if (widget == buttons[i]) {
/*  47 */             result[0] = (i - 1);
/*  48 */             break;
/*     */           }
/*     */         }
/*  51 */         shell.close();
/*     */       }
/*     */     };
/*  55 */     if (check != null) {
/*  56 */       buttons[0] = new Button(shell, 32);
/*  57 */       buttons[0].setText(check);
/*  58 */       buttons[0].setSelection(checkValue[0] != 0);
/*  59 */       data = new GridData();
/*  60 */       data.horizontalAlignment = 3;
/*  61 */       buttons[0].setLayoutData(data);
/*     */     }
/*     */ 
/*  64 */     Composite composite = new Composite(shell, 0);
/*  65 */     data = new GridData();
/*  66 */     data.horizontalAlignment = 3;
/*  67 */     composite.setLayoutData(data);
/*  68 */     composite.setLayout(new RowLayout());
/*     */ 
/*  70 */     if (button1 != null) {
/*  71 */       buttons[1] = new Button(composite, 8);
/*  72 */       buttons[1].setText(button1);
/*  73 */       buttons[1].addListener(13, listener);
/*     */     }
/*     */ 
/*  76 */     if (button2 != null) {
/*  77 */       buttons[2] = new Button(composite, 8);
/*  78 */       buttons[2].setText(button2);
/*  79 */       buttons[2].addListener(13, listener);
/*     */     }
/*     */ 
/*  82 */     if (button3 != null) {
/*  83 */       buttons[3] = new Button(composite, 8);
/*  84 */       buttons[3].setText(button3);
/*  85 */       buttons[3].addListener(13, listener);
/*     */     }
/*     */ 
/*  88 */     shell.pack();
/*  89 */     shell.open();
/*  90 */     Display display = parent.getDisplay();
/*  91 */     while (!(shell.isDisposed()))
/*  92 */       if (!(display.readAndDispatch()))
/*  93 */         display.sleep();
/*     */   }
/*     */ 
/*     */   public void prompt(final String title, String text, final String check,final  String[] value, final int[] checkValue, final int[] result)
/*     */   {
/*  98 */     final Shell parent = getParent();
/*  99 */     final Shell shell = new Shell(parent, 67680);
/* 100 */     if (title != null) {
/* 101 */       shell.setText(title);
/*     */     }
/* 103 */     GridLayout gridLayout = new GridLayout();
/* 104 */     shell.setLayout(gridLayout);
/* 105 */     Label label = new Label(shell, 64);
/* 106 */     label.setText(text);
/* 107 */     GridData data = new GridData();
/* 108 */     data.horizontalAlignment = 4;
/* 109 */     data.grabExcessHorizontalSpace = true;
/* 110 */     label.setLayoutData(data);
/*     */ 
/* 112 */     final Text valueText = new Text(shell, 2048);
/* 113 */     if (value[0] != null)
/* 114 */       valueText.setText(value[0]);
/* 115 */     data = new GridData();
/* 116 */     data.horizontalAlignment = 4;
/* 117 */     data.grabExcessHorizontalSpace = true;
/* 118 */     valueText.setLayoutData(data);
/*     */ 
/* 120 */     final Button[] buttons = new Button[3];
/* 121 */     Listener listener = new Listener() {
/*     */       public void handleEvent(Event event) {
/* 123 */         if (buttons[0] != null) checkValue[0] = ((buttons[0].getSelection()) ? 1 : 0);
/* 124 */         value[0] = valueText.getText();
/* 125 */         result[0] = ((event.widget == buttons[1]) ? 1 : 0);
/* 126 */         shell.close();
/*     */       }
/*     */     };
/* 130 */     if (check != null) {
/* 131 */       buttons[0] = new Button(shell, 32);
/* 132 */       buttons[0].setText(check);
/* 133 */       buttons[0].setSelection(checkValue[0] != 0);
/* 134 */       data = new GridData();
/* 135 */       data.horizontalAlignment = 3;
/* 136 */       buttons[0].setLayoutData(data);
/*     */     }
/*     */ 
/* 139 */     Composite composite = new Composite(shell, 0);
/* 140 */     data = new GridData();
/* 141 */     data.horizontalAlignment = 3;
/* 142 */     composite.setLayoutData(data);
/* 143 */     composite.setLayout(new RowLayout());
/* 144 */     buttons[1] = new Button(composite, 8);
/* 145 */     buttons[1].setText(SWT.getMessage("SWT_OK"));
/* 146 */     buttons[1].addListener(13, listener);
/* 147 */     buttons[2] = new Button(composite, 8);
/* 148 */     buttons[2].setText(SWT.getMessage("SWT_Cancel"));
/* 149 */     buttons[2].addListener(13, listener);
/*     */ 
/* 151 */     shell.pack();
/* 152 */     shell.open();
/* 153 */     Display display = parent.getDisplay();
/* 154 */     while (!(shell.isDisposed()))
/* 155 */       if (!(display.readAndDispatch()))
/* 156 */         display.sleep();
/*     */   }
/*     */ 
/*     */   public void promptUsernameAndPassword(String title, final String text, final String check, final String[] user, final String[] pass, final int[] checkValue, final int[] result)
/*     */   {
/* 161 */     Shell parent = getParent();
/* 162 */     final Shell shell = new Shell(parent, 67680);
/* 163 */     shell.setText(title);
/* 164 */     GridLayout gridLayout = new GridLayout();
/* 165 */     shell.setLayout(gridLayout);
/* 166 */     Label label = new Label(shell, 64);
/* 167 */     label.setText(text);
/* 168 */     GridData data = new GridData();
/* 169 */     data.horizontalAlignment = 4;
/* 170 */     data.grabExcessHorizontalSpace = true;
/* 171 */     label.setLayoutData(data);
/*     */ 
/* 173 */     Label userLabel = new Label(shell, 0);
/* 174 */     userLabel.setText(SWT.getMessage("SWT_Username"));
/*     */ 
/* 176 */     final Text userText = new Text(shell, 2048);
/* 177 */     if (user[0] != null)
/* 178 */       userText.setText(user[0]);
/* 179 */     data = new GridData();
/* 180 */     data.horizontalAlignment = 4;
/* 181 */     data.grabExcessHorizontalSpace = true;
/* 182 */     userText.setLayoutData(data);
/*     */ 
/* 184 */     Label passwordLabel = new Label(shell, 0);
/* 185 */     passwordLabel.setText(SWT.getMessage("SWT_Password"));
/*     */ 
/* 187 */     final Text passwordText = new Text(shell, 4196352);
/* 188 */     if (pass[0] != null)
/* 189 */       passwordText.setText(pass[0]);
/* 190 */     data = new GridData();
/* 191 */     data.horizontalAlignment = 4;
/* 192 */     data.grabExcessHorizontalSpace = true;
/* 193 */     passwordText.setLayoutData(data);
/*     */ 
/* 195 */     final Button[] buttons = new Button[3];
/* 196 */     Listener listener = new Listener() {
/*     */       public void handleEvent(Event event) {
/* 198 */         if (buttons[0] != null) checkValue[0] = ((buttons[0].getSelection()) ? 1 : 0);
/* 199 */         user[0] = userText.getText();
/* 200 */         pass[0] = passwordText.getText();
/* 201 */         result[0] = ((event.widget == buttons[1]) ? 1 : 0);
/* 202 */         shell.close();
/*     */       }
/*     */     };
/* 206 */     if (check != null) {
/* 207 */       buttons[0] = new Button(shell, 32);
/* 208 */       buttons[0].setText(check);
/* 209 */       buttons[0].setSelection(checkValue[0] != 0);
/* 210 */       data = new GridData();
/* 211 */       data.horizontalAlignment = 3;
/* 212 */       buttons[0].setLayoutData(data);
/*     */     }
/*     */ 
/* 215 */     Composite composite = new Composite(shell, 0);
/* 216 */     data = new GridData();
/* 217 */     data.horizontalAlignment = 3;
/* 218 */     composite.setLayoutData(data);
/* 219 */     composite.setLayout(new RowLayout());
/* 220 */     buttons[1] = new Button(composite, 8);
/* 221 */     buttons[1].setText(SWT.getMessage("SWT_OK"));
/* 222 */     buttons[1].addListener(13, listener);
/* 223 */     buttons[2] = new Button(composite, 8);
/* 224 */     buttons[2].setText(SWT.getMessage("SWT_Cancel"));
/* 225 */     buttons[2].addListener(13, listener);
/*     */ 
/* 227 */     shell.pack();
/* 228 */     shell.open();
/* 229 */     Display display = parent.getDisplay();
/* 230 */     while (!(shell.isDisposed()))
/* 231 */       if (!(display.readAndDispatch()))
/* 232 */         display.sleep();
/*     */   }
/*     */ }
